<? $this->view('head') ?>
<title>应住记录</title>
<link rel="stylesheet" href="<?= $this->www('css/module/master.css') ?>" type="text/css" media="screen" />
<link rel="stylesheet" href="<?= $this->www('css/module/master/report.css') ?>" type="text/css" />
<script type="text/javascript" src="<?= $this->www('script/module/master.stat.js') ?>"></script>

<? $this->view('body') ?>
<? $this->view('master/header', array('tab' => 'bbtj')) ?>

<div class="ftt-container">
    <div class="ftt-title clearfix">
        <h2 class="column-left">应住记录 [ <?= $this->date ?> ]</h2>
        <input id="print-button" class="column-right button white" type="button" value="打印报表" onclick="window.print();" />
        <input id="force-button" class="column-right button white" type="button" value="导出报表" title="将当前报表导出为CSV格式下载" onclick="location.href=location.pathname+'.csv'+location.search;" />
    </div>
    <div class="reports-query">
        <form action="/master/stat/yzjl" method="get">
            <label for="reports-date">选择日期</label>
            <input type="text" name="date" id="reports-date" class="ftt-input-text short-text input-datepicker" value="<?= $this->date ?>" />
            <input type="submit" class="button white" value="查询" />
        </form>
    </div>
    <div class="reports-wrapper">
        <p class="utime">
            当前列表数据更新时间：<span class="update-T"><?= date('Y-m-d H:i:s', $this->time) ?></span>
        </p>
        <table class="report">
            <thead>
                <tr>
                    <th>订单编号</th>
                    <th>房间</th>
                    <th>入住客人姓名</th>
                    <th>入住客人手机</th>
                    <th>预计入住</th>
                    <th>预计退房</th>
                    <th>间夜</th>
                    <th>成交房费（元）</th>
                    <th>账单房费（元）</th>
                    <th>账单编号</th>
                </tr>
            </thead>
            <tbody>
                <? $live_sum = $pval_sum = $bval_sum = 0 ?>
                <? if(empty($this->yzjl)): ?>
                <tr>
                    <td colspan="10" class="none">无记录</td>
                </tr>
                <? else: ?>
                <? foreach ($this->yzjl as $data): ?>
                <tr>
                    <td rowspan="2"><a target="_blank" title="订单详情" href="/master/order/detail?oid=<?= $data['o_id'] ?>"><?= $data['o_id'] ?></a></td>
                    <td><?= $this->escape($data['o_room']) ?></td>
                    <td><?= $this->escape($data['o_glver_name']) ?></td>
                    <td><?= $this->escape($data['o_glver_phone']) ?></td>
                    <td><?= date("Y-m-d H:i", $data['o_btime']) ?></td>
                    <td><?= date("Y-m-d H:i", $data['o_etime']) ?></td>
                    <td><?= ($live = ($data['o_edatm']-$data['o_bdatm'])/86400) ?><? $live_sum += $live ?></td>
                    <td><?= $data['o_price']/100 ?><? $pval_sum += $data['o_price'] ?></td>
                    <td><?= $data['o_brice']/100 ?><? $bval_sum += $data['o_brice'] ?></td>
                    <td><a target="_blank" title="账单详情" href="/master/bill/detail?bid=<?= $data['o_bid'] ?>"><?= $data['o_bid'] ?></a></td>
                </tr>
                <tr>
                    <td colspan="9" align="left">备注：<?= $this->escape($data['o_memo']) ?></td>
                </tr>
                <? endforeach; ?>
                <? endif; ?>
            </tbody>
            <tfoot>
                <tr>
                    <td colspan="6" style="text-align:right">共有&nbsp;<?= count($this->yzjl) ?>&nbsp;条记录，合计：</td>
                    <td><?= $live_sum ?></td>
                    <td><?= $pval_sum/100 ?></td>
                    <td><?= $bval_sum/100 ?></td>
                    <td></td>
                </tr>
				<tr>
					<td colspan="10" style="text-align:right;color:#686868;">
                        注：本报表仅统计保留订单
					</td>
				</tr>
            </tfoot>
        </table>
        <p class="copyright">——由房态通提供的报表</p>
    </div>
</div>

<? $this->view('master/footer') ?>
<script type="text/javascript">$(Z.Module.master.stat.yzjl.init)</script>
<? $this->view('foot') ?>
